<template>
  <div>
    <el-dialog
      :visible.sync="isShowDialogs"
      width="1200px"
      :title="title"
      center
      :close-on-press-escape="false"
      :close-on-click-modal="false"
    >
      <div v-if="accountProfileDetail" class="resume">
        <div class="resume_left">
          <div class="resume_left_info">
            <div class="resume_basic_modify">
              <img width="150px" height="150px" style="object-fit: fill" :src="accountProfileDetail.avatar">
            </div>
            <div>
              <h3 class="titleColor">{{ accountProfileDetail.nickName }}(ID:{{ accountProfileDetail.userId }})</h3>
              <p>
                <span>{{ accountProfileDetail.birthday !== null && age !== 0 ? age + "岁": "" }}</span>
                <span>{{ accountProfileDetail.sex === 1 ? "男" : "女" }}</span>
                <span>{{ accountProfileDetail.educationName }}</span>
                <span>{{ joinTime }}</span>
              </p>
              <p>
                <span v-if="accountProfileDetail.certificateStatus === 1">{{ '有教师资格证' }}</span>
                <span v-if="accountProfileDetail.certificateStatus === 2">{{ '教师资格证考取中' }}</span>
                <span v-if="accountProfileDetail.certificateStatus === 3">{{ '无教师资格证' }}</span>
                <span>{{ jobIntention ? jobIntention.hierarchyName : '' }}</span></p>
              <p>
                <span>现居地址:</span>
                <span>&nbsp;</span>
                <span v-if="accountProfileDetail.liveAddressProvince === '' || accountProfileDetail.liveAddressCity === ''">{{ '暂未填写' }}</span>
                <span v-else>{{ accountProfileDetail.liveAddressProvince }}{{ accountProfileDetail.liveAddressCity }}</span></p>
              <p>
                <span>联系方式:</span>
                <span>&nbsp;</span>
                <span>{{ accountProfileDetail.phone == null ? "" : accountProfileDetail.phone }}</span></p>
            </div>
          </div>
          <div class="resume_position_info">
            <h3 class="titleColor">求职意向&nbsp;{{ jobIntention ? `${(jobIntention.jobWantedName)}` : '' || '' }}</h3>
            <span v-if="jobIntention == null">暂未填写</span>
            <ul v-else>
              <li>
                <label>意向职位:</label>&nbsp;
                <span>{{ jobIntention.positionName!=='' ? jobIntention.positionName : '暂未填写' }}</span>
              </li>
              <li>
                <label>薪资待遇:</label>&nbsp;
                <span v-if="!jobIntention || jobIntention.salaryMin == null || jobIntention.salaryMax == null">暂未填写</span>
                <span v-if="jobIntention.salaryMin === 0 && jobIntention.salaryMax === 0">面议</span>
                <span v-else>{{ jobIntention.salaryMin }}-{{ jobIntention.salaryMax }}/月</span>
              </li>
              <li>
                <label>工作性质:</label>&nbsp;
                <span>{{ accountProfileDetail.workNature === 1 ? "全职" : "兼职" }}</span>
              </li>
              <li>
                <label>到岗时间:</label>&nbsp;
                <span>{{ jobIntention.startTimeName === '' ? '暂未填写' : jobIntention.startTimeName }}</span>
              </li>
              <li>
                <label>意向城市:</label>&nbsp;
                <span>{{ jobIntention.intentionProvinceName === "" ? '暂未填写' : intention_city_string }}</span>
              </li>
              <li>
                <label>期望福利:</label>&nbsp;
                <span>{{ jobIntention.welfareNames === "" ? '暂未填写' : jobIntention.welfareNames }}</span>
              </li>
            </ul>
          </div>
        </div>
        <div class="resume_right">
          <div>
            <h3 class="titleColor">求学经历</h3>
            <p v-if="experiences.length===0" style="margin-bottom: 15px">暂未填写</p>
            <div v-for="(item,index) of experiences" :key="index" class="school_experience">
              <h4 class="lightHighTitle">{{ item.schoolName }}</h4>
              <p>{{ item.admissionTime | parseTime("{y}-{m}") }} ~ {{ item.graduationTime | parseTime("{y}-{m}") }}</p>
              <p>
                <span>{{ item.majorName }}</span>&nbsp;
                <span>{{ item.educationName }}</span>
              </p>
              <p>
                <span>{{ item.majorType === 1 ? "师范类" : "非师范类" }}</span>&nbsp;
                <span>{{ item.isFullTime === 1 ? "全日制" : "非全日制" }}</span>
              </p>
            </div>
          </div>
          <div>
            <h3 class="titleColor">工作经历</h3>
            <p v-if="works.length===0" style="margin-bottom: 15px">暂未填写</p>
            <div v-for="(item,index) of works" :key="index" class="work_experience">
              <h4 class="lightHighTitle">{{ item.businessName }}</h4>
              <p>{{ item.entryTime | parseTime("{y}-{m}") }}~ {{ item.quitTime | parseTime("{y}-{m}") }}</p>
              <p>
                <span>{{ item.positionName }}</span>
              </p>
              <p v-html="item.workDescribe" />
            </div>
          </div>
        </div>
      </div>
      <div class="closeBtn">
        <el-button type="primary" @click="isShowDialogs=false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as power from '@/api/recruitment'
import mixinOptions from '@/views/recruitment/power/getListOptions'
export default {
  mixins: [mixinOptions],
  props: {
    isShowDialog: {
      type: Boolean,
      default: false
    },
    userId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      accountProfileDetail: null,
      jobIntention: null,
      experiences: [],
      works: [],
      joinTime: '',
      intention_city_string: '',
      age: '',
      title: ''
    }
  },
  computed: {
    isShowDialogs: {
      get(val) {
        return this.isShowDialog
      },
      set(val) {
        this.$emit('closeDialog', val)
      }
    }
  },
  methods: {
    check_Teacher_Resume_Detail(id) {
      this.accountProfileDetail = null
      this.jobIntention = null
      this.experiences = []
      this.works = []
      this.joinTime = ''
      this.intention_city_string = ''
      this.age = ''
      power.getTeacherInfo({ id }).then(res => {
        const { data } = res
        this.title = '老师详情'
        this.accountProfileDetail = data.accountProfile
        if (data.accountProfile.avatar === '' || data.accountProfile == null) {
          this.accountProfileDetail.avatar = 'http://ossdev0.jiabala.com/bduHjrswEDdFO'
        }
        this.experiences = data.experiences.length > 0 ? data.experiences : []
        this.works = data.works.length > 0 ? data.works : []
        this.works.forEach((item) => {
          item.workDescribe = item.workDescribe.replace(/\n/g, '<br>')
        })
        this.jobIntention = !data.jobIntention && typeof data.jobIntention !== 'undefined' && data.jobIntention !== 0 ? null : data.jobIntention
        if (data.jobIntention !== null && data.jobIntention.intentionProvinceName !== '') {
          let _provide = []
          let _city = []
          let _intention_city = ''
          _provide = data.jobIntention.intentionProvinceName.split(',')
          _city = data.jobIntention.intentionCityName.split(',')
          _provide.forEach((item, index) => {
            _intention_city += _provide[index] + _city[index] + ','
          })
          this.intention_city_string = _intention_city.substr(0, _intention_city.length - 1)
        }
        if (data.accountProfile.birthday) {
          this.age = this.computedAgeOrWorkTime(res.data.accountProfile.birthday / 1000, true) <= -1 ? 1 : this.computedAgeOrWorkTime(res.data.accountProfile.birthday / 1000, true)
        } else {
          this.age = '暂未填写'
        }
        const date = new Date()
        const time = new Date(res.data.accountProfile.joinWorkTime)
        const yearNow = date.getFullYear()
        const workYear = time.getFullYear()
        this.joinTime = yearNow - workYear <= 0 ? '1年内工作经验' : yearNow - workYear + '年工作经验'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
  .resume{
    display: flex;
    min-height: 550px;
    .resume_left{
      width: 50%;
      border-right: 2px solid #5b90ff;
      .resume_left_info{
        display: flex;
        margin-bottom: 20px;
        .resume_basic_modify{
          margin-right: 25px;
        }
      }
      .resume_position_info{
        margin-top: 25px;
        ul{
          margin: 0;
          padding: 0;
          li{
            list-style: none;
            margin: 20px 0;
          }
        }
      }
    }
    .resume_right{
      flex: 1;
      max-height: 500px;
      overflow: auto;
      margin-left: 15px;
      h4 , p{
        margin: 5px 0;
        padding: 0;
      }
      .school_experience , .work_experience{
        margin-bottom: 20px;
      }
    }
    .titleColor{
      color: #5b90ff;
      font-size: 20px;
      margin-top: 0;
    }
    .lightHighTitle{
      font-size: 16px;
    }
  }
    .closeBtn{
      width: 100%;
      display: flex!important;
      justify-content: center!important;
      margin-top: 20px;
    }
</style>
